package com.xbongbong.paas.service;

import com.xbongbong.paas.domain.entity.ext.PaasFormEntityExt;
import com.xbongbong.paas.pojo.dto.BusinessRuleWhiteDTO;
import com.xbongbong.paas.pojo.dto.CoUserPermissionListDTO;
import com.xbongbong.paas.pojo.dto.CoUserPermissionUpdateDTO;
import com.xbongbong.paas.pojo.dto.ComboLinkExplainListDTO;
import com.xbongbong.paas.pojo.dto.CustomRepeatLinkExplainDTO;
import com.xbongbong.paas.pojo.dto.FieldTypeListDTO;
import com.xbongbong.paas.pojo.dto.FormAddDTO;
import com.xbongbong.paas.pojo.dto.FormAllListDTO;
import com.xbongbong.paas.pojo.dto.FormDecisionInfoUpdateDTO;
import com.xbongbong.paas.pojo.dto.FormGetDTO;
import com.xbongbong.paas.pojo.dto.FormListDTO;
import com.xbongbong.paas.pojo.dto.FormRoleDetailDTO;
import com.xbongbong.paas.pojo.dto.FormRoleUpdateDTO;
import com.xbongbong.paas.pojo.dto.FormTitleListDTO;
import com.xbongbong.paas.pojo.dto.FormUpdateDTO;
import com.xbongbong.paas.pojo.dto.MenuFormCopyDTO;
import com.xbongbong.paas.pojo.dto.UpdateExplainStageDTO;
import com.xbongbong.paas.pojo.dto.UserApproveListDTO;
import com.xbongbong.paas.pojo.vo.BusinessRuleWhiteVO;
import com.xbongbong.paas.pojo.vo.CoUserPermissionListVO;
import com.xbongbong.paas.pojo.vo.CoUserPermissionUpdateVO;
import com.xbongbong.paas.pojo.vo.ComboLinkExplainListVO;
import com.xbongbong.paas.pojo.vo.FieldTypeListVO;
import com.xbongbong.paas.pojo.vo.FormAddVO;
import com.xbongbong.paas.pojo.vo.FormAllListVO;
import com.xbongbong.paas.pojo.vo.FormDecisionInfoGetVO;
import com.xbongbong.paas.pojo.vo.FormGetVO;
import com.xbongbong.paas.pojo.vo.FormListVO;
import com.xbongbong.paas.pojo.vo.FormRoleDetailVO;
import com.xbongbong.paas.pojo.vo.FormRoleUpdateVO;
import com.xbongbong.paas.pojo.vo.FormTitleListVO;
import com.xbongbong.paas.pojo.vo.FormUpdateVO;
import com.xbongbong.paas.pojo.vo.MenuFormCopyVO;
import com.xbongbong.paas.pojo.vo.MenuListVO;
import com.xbongbong.paas.pojo.vo.UserApproveListVO;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.BaseDTO;
import com.xbongbong.paas.toolbox.wrap.BaseVO;
import com.xbongbong.paas.toolbox.wrap.UserVO;
import com.xbongbong.pro.businesstage.pojo.dto.RuleEnableDTO;
import com.xbongbong.pro.form.pojo.dto.AllAppFormListDTO;
import com.xbongbong.pro.form.pojo.dto.AppFormListDTO;
import com.xbongbong.pro.form.pojo.dto.BusinessFieldDTO;
import com.xbongbong.pro.form.pojo.dto.ClueConvertRuleSaveDTO;
import com.xbongbong.pro.form.pojo.dto.ClueConvertRulesListSaveDTO;
import com.xbongbong.pro.form.pojo.dto.EnableAssociationListDTO;
import com.xbongbong.pro.form.pojo.dto.FieldConvertRuleDTO;
import com.xbongbong.pro.form.pojo.dto.FormAddBatchDTO;
import com.xbongbong.pro.form.pojo.dto.FormAssociationListDTO;
import com.xbongbong.pro.form.pojo.dto.FormBusinessRuleDTO;
import com.xbongbong.pro.form.pojo.dto.FormDeleteDTO;
import com.xbongbong.pro.form.pojo.dto.FormRuleListDTO;
import com.xbongbong.pro.form.pojo.dto.FormUpdateBatchDTO;
import com.xbongbong.pro.form.pojo.dto.FormUpdateBusinessRuleDTO;
import com.xbongbong.pro.form.pojo.dto.FormUpdateNameDTO;
import com.xbongbong.pro.form.pojo.dto.HomePageDeleteDTO;
import com.xbongbong.pro.form.pojo.dto.HomePageUpdateDTO;
import com.xbongbong.pro.form.pojo.vo.AllAppFormListVO;
import com.xbongbong.pro.form.pojo.vo.BusinessFieldVO;
import com.xbongbong.pro.form.pojo.vo.ClueConvertRuleVO;
import com.xbongbong.pro.form.pojo.vo.CustomRepeatLinkExplainGetVO;
import com.xbongbong.pro.form.pojo.vo.EnableAssociationListVO;
import com.xbongbong.pro.form.pojo.vo.FieldConvertRuleVO;
import com.xbongbong.pro.form.pojo.vo.FormAddBatchVO;
import com.xbongbong.pro.form.pojo.vo.FormAssociationListVO;
import com.xbongbong.pro.form.pojo.vo.FormBusinessRuleVO;
import com.xbongbong.pro.form.pojo.vo.FormDeleteVO;
import com.xbongbong.pro.form.pojo.vo.FormRuleListVO;
import com.xbongbong.pro.form.pojo.vo.FormUpdateBatchVO;
import com.xbongbong.pro.form.pojo.vo.FormUpdateBusinessRuleVO;
import com.xbongbong.pro.form.pojo.vo.FormUpdateNameVO;
import com.xbongbong.pro.form.pojo.vo.HomePageListVO;
import com.xbongbong.pro.form.pojo.vo.SupportLinkageFieldsVO;
import com.xbongbong.pro.form.pojo.vo.UpdateExplainStageVO;
import com.xbongbong.pro.menu.pojo.dto.QuickNewListDTO;
import com.xbongbong.pro.menu.pojo.vo.QuickNewListVO;

import java.util.List;
import java.util.Map;

/**
 * @author: wufeng
 * @date: 2018/8/13 17:34
 * @desrcption: 表单操作
 */
public interface PaasFormService {
    /**
     * 添加表单设计
     * @param formAddDTO
     * @return
     * @throws XbbException
     */

    FormAddVO add(FormAddDTO formAddDTO) throws XbbException;

    /**
     * 表单复制
     * @param menuFormCopyDTO
     * @return
     * @throws XbbException
     */
    MenuFormCopyVO copy(MenuFormCopyDTO menuFormCopyDTO) throws XbbException;

    /**
     * 批量插入表单主表数据
     * @param formAddBatchDTO
     * @return
     * @throws XbbException
     */
    FormAddBatchVO addBatch(FormAddBatchDTO formAddBatchDTO) throws XbbException;

    /**
     * 批量更新表单信息
     * @author 吴峰
     * @date 2019/2/19 19:21
     * @param formUpdateBatchDTO
     * @return
     * @throws XbbException 业务异常
     */
    FormUpdateBatchVO updateBatch(FormUpdateBatchDTO formUpdateBatchDTO) throws XbbException;
    /**
     * 批量更新表单信息
     * @author 吴峰
     * @date 2019/2/19 19:21
     * @param formUpdateBatchDTO
     * @return
     * @throws XbbException 业务异常
     */
    FormUpdateBatchVO updateBatch4Mirror(FormUpdateBatchDTO formUpdateBatchDTO) throws XbbException;

    /**
     * 检索表单的相应属性信息
     * @author wufeng
     * @date 2018/8/13 17:53
     * @param formGetDTO
     * @descption
     * @return FormGetVO
     * @throws XbbException
     */
    FormGetVO get(FormGetDTO formGetDTO) throws XbbException;

    /**
     * 保存表单设计阶段的数据
     * @param formUpdateDTO
     * @return FormUpdateVO
     * @throws XbbException
     */
    FormUpdateVO update(FormUpdateDTO formUpdateDTO) throws XbbException;

    /**
     * 查看字段列表
     * @param fieldTypeListDTO
     * @return FieldTypeListVO
     * @throws XbbException
     */
    FieldTypeListVO fieldTypeList(FieldTypeListDTO fieldTypeListDTO) throws XbbException;

    /**
     * 协同人权限获取
     * @param coUserListDTO
     * @return
     * @throws XbbException
     */
    CoUserPermissionListVO synergeticList(CoUserPermissionListDTO coUserListDTO) throws XbbException;

    /**
     * 协同人权限设置
     * @param synergeticUpdateDTO
     * @return CoUserPermissionUpdateVO
     * @throws XbbException
     */
    CoUserPermissionUpdateVO synergeticUpdate(CoUserPermissionUpdateDTO synergeticUpdateDTO) throws XbbException;

    /**
     * 检索当前应用的表单或者流程表单
     * @param formListDTO
     * @return
     * @throws XbbException
     */
    FormListVO formList(FormListDTO formListDTO) throws XbbException;

    /**
     * 日志检索当前应用启用的菜单
     * @param formListDTO
     * @return
     * @throws XbbException
     */
    MenuListVO logMenuList(FormListDTO formListDTO) throws XbbException;

    /**
     * 检索所有应用的表单或者流程表单(type=2,3)
     * 菜单类型，1 分组，2 表单，3 表单(开启流程)，4 统计
     * @param formAllListDTO
     * @return
     * @throws XbbException
     */
    FormAllListVO getAllformList(FormAllListDTO formAllListDTO) throws XbbException;

    /**
     * 检索用户的审批表单
     * @param userApproveListDTO
     * @return
     * @throws XbbException
     */
    UserApproveListVO userApproveList(UserApproveListDTO userApproveListDTO) throws XbbException;


    /**
     * 获取标题列表
     * @param formTitleListDTO
     * @return
     * @throws XbbException
     */
    FormTitleListVO titleList(FormTitleListDTO formTitleListDTO) throws XbbException;

    /**
     * 获取角色对应的该表单权限信息
     * @param roleDetailDTO 相关业务DTO
     * @return 相关业务VO
     * @throws XbbException 业务异常
     */
    FormRoleDetailVO roleDetail(FormRoleDetailDTO roleDetailDTO) throws XbbException;

    /**
     * 设置角色对应的该表单权限信息
     * @param roleUpdateDTO 相关业务DTO
     * @return 相关业务VO
     * @throws XbbException 业务异常
     */
    FormRoleUpdateVO roleUpdate(FormRoleUpdateDTO roleUpdateDTO) throws XbbException;

    /**
     * 当前应用的所有表单（除自己外）和字段列表
     * @param comboLinkExplainListDTO
     * @return 返回关联其他表单的符合条件的字段
     * @see com.xbongbong.paas.enums.ComboLinkFieldEnum
     * @throws XbbException
     */
    ComboLinkExplainListVO comboLinkExplainList(ComboLinkExplainListDTO comboLinkExplainListDTO) throws XbbException;

    /**
     * 获取表单名称
     * @param corpid
     * @param code
     * @return
     */
    Map<Long,String> getNameMap(String corpid, int code);

    /**
     * 获取快捷新建表单列表
     * @param quickNewListDTO
     * @return
     * @throws XbbException
     */
    QuickNewListVO quickNewList(QuickNewListDTO quickNewListDTO) throws XbbException;

    /**
     * 更新表单名称
     * @param formUpdateNameDTO
     * @return
     * @throws XbbException
     */
    FormUpdateNameVO updateName(FormUpdateNameDTO formUpdateNameDTO) throws XbbException;

    /**
     * Description: 获取启用的form表单(加了工单的特殊处理，PaasFormModel还有一个那是获取除工单的)
     * @param loginUser
     * @param businessType 业务类型
     * @param appId 应用id
     * @return java.util.List<com.xbongbong.paas.domain.entity.ext.PaasFormEntityExt>
     * @author 魏荣杰
     * @date 2019/5/16 14:13
     * @since v1.0
     */
    List<PaasFormEntityExt> getEnableFormList(UserVO loginUser, Integer businessType, Long appId, Integer distributorMark) throws XbbException;

    /**
     * 获取全部应用和表单 不包含工作报告
     * @param allAppFormListDTO
     * @return
     * @throws XbbException
     */
    AllAppFormListVO getAllAppFormList(AllAppFormListDTO allAppFormListDTO) throws XbbException;
    /**
     * 获取全部应用和表单 包含 工作报告
     * @param appFormListDTO
     * @return
     * @throws XbbException
     */
    AllAppFormListVO getAppFormList(AppFormListDTO appFormListDTO) throws XbbException;
    /**
     * 删除表单
     * @param formDeleteDTO
     * @return
     * @throws XbbException
     */
    FormDeleteVO delete(FormDeleteDTO formDeleteDTO) throws XbbException;

    /**
     * Description: 获取启用的form表单(加了工单的特殊处理，PaasFormModel还有一个那是获取除工单的)
     * @param loginUser
     * @return java.util.List<com.xbongbong.paas.domain.entity.ext.PaasFormEntityExt>
     * @author chy
     * @date 2019/6/20 8:18 PM
     * @since v1.0
     */
    List<PaasFormEntityExt> getEnableCustomerFormList(UserVO loginUser);

    List<PaasFormEntityExt> getEnableCustomerFormListDistributor(UserVO loginUser, Integer distributorMark);

    List<PaasFormEntityExt> getEnableContractFormList(UserVO loginUser);

    List<PaasFormEntityExt> getEnableContractFormListDistributor(UserVO loginUser, Integer distributorMark);

    List<PaasFormEntityExt> getEnableClueFormList(UserVO loginUser);

    List<PaasFormEntityExt> getEnableContactFormList(UserVO loginUser);

    /**
     * 根据权限 删除没有权限的表单
     * @param paasFormEntityList
     * @param loginUser
     * 创建时间 2019/6/7 4:03 PM
     * 修改时间 2019/6/7 4:03 PM
     * @author chy
     * @since v1.0
     * @version v1.0
     */
    void removeByPermission(List<PaasFormEntityExt> paasFormEntityList, UserVO loginUser);

    /**
     * 启用关联列表
     * @param enableAssociationListDTO
     * @return
     * @throws XbbException
     */
    EnableAssociationListVO enableAssociation(EnableAssociationListDTO enableAssociationListDTO) throws XbbException;

    /**
     * 校验版本以及白名单
     * @param businessRuleWhiteDTO
     * @author xingxing.xiao
     * @date 2020/05/11 15:52
     */
    BusinessRuleWhiteVO validateVersionAndWhite(BusinessRuleWhiteDTO businessRuleWhiteDTO) throws XbbException;

    /**
     * 关联列表
     * @param formAssociationListDTO
     * @return
     * @throws XbbException
     */
    FormAssociationListVO associationList(FormAssociationListDTO formAssociationListDTO) throws XbbException;

    /**
     * 字段映射
     * @param fieldConvertRuleDTO
     * @return
     * @throws XbbException
     */
    FieldConvertRuleVO getFieldConvertRule(FieldConvertRuleDTO fieldConvertRuleDTO) throws XbbException;

    /**
     * 字段映射保存
     * @param fieldConvertRuleDTO
     * @return
     * @throws XbbException
     */
    BaseVO fieldConvertSave(FieldConvertRuleDTO fieldConvertRuleDTO) throws XbbException;

    /**
     * 更新业务规则
     * @param formUpdateBusinessRuleDTO
     * @return
     * @throws XbbException
     */
    FormUpdateBusinessRuleVO updateBusinessRule(FormUpdateBusinessRuleDTO formUpdateBusinessRuleDTO) throws XbbException;

    /**
     * 业务规则列表
     * @param formBusinessRuleDTO
     * @return
     * @throws XbbException
     */
    FormBusinessRuleVO businessRuleList(FormBusinessRuleDTO formBusinessRuleDTO) throws XbbException;

    /**
     * 产品表单的formId取缓存吧
     * @param corpid
     * @param businessType
     * @return
     * @throws XbbException
     */
    Long getFormIdByBusinessType(String corpid, int businessType) throws XbbException;

    /**
     * 查询单条数据，判断查询出来的configValue的状态码是1还是0，1则返回true,0则返回false
     * @param corpid
     * @param config
     * @param formId
     * @return
     * @throws XbbException
     */
    Boolean getSingleRuleList(String corpid, String config, Long formId) throws XbbException;


    /**
     * 获取首页列表
     * @param baseDTO 入参
     * @return 首页列表
     * @throws XbbException error
     * @author zhouwq
     * @date 2020/9/1 15:34
     */
    HomePageListVO homePageList(BaseDTO baseDTO) throws XbbException;

    /**
     * 首页列表配置更新
     * @param homePageUpdateDTO 入参
     * @return BaseVO
     * @throws XbbException error
     * @author zhouwq
     * @date 2020/9/1 15:34
     */
    BaseVO homePageUpdate(HomePageUpdateDTO homePageUpdateDTO) throws XbbException;

    /**
     * 首页列表配置删除 by 图表categoryId
     * @param homePageDeleteDTO 入参
     * @return BaseVO
     * @throws XbbException error
    * @author zhouwq
    * @date 2020/12/15 9:28
     */
    BaseVO homePageDelete(HomePageDeleteDTO homePageDeleteDTO) throws XbbException;


    /**
     * 关联“设置更新规则”列表
     * @param formRuleListDTO
     * @return
     */
    FormRuleListVO getRuleList(FormRuleListDTO formRuleListDTO) throws XbbException;

    /**
     * 更新规则的启用接口
     * @param ruleEnableDTO
     * @return
     * @throws XbbException
     */
    public BaseVO enableChangeTime(RuleEnableDTO ruleEnableDTO) throws XbbException;

    /**
     *
     * @param formDeleteDTO
     * @return
     * @throws XbbException
     */
    FormDeleteVO deleteByPackage(FormDeleteDTO formDeleteDTO) throws XbbException;


    /**
     * 获取工商查询匹配的所有字段
     * @param businessFieldDTO
     * @return
     * @throws XbbException
     */
    BusinessFieldVO businessFieldList(BusinessFieldDTO businessFieldDTO) throws XbbException;

    ClueConvertRuleVO getClueConvertRule(ClueConvertRuleSaveDTO clueConvertRuleSaveDTO) throws XbbException;

    BaseVO clueConverSave(ClueConvertRuleSaveDTO clueConvertRuleSaveDTO) throws XbbException;

    BaseVO clueConverRulesListSave(ClueConvertRulesListSaveDTO clueConvertRulesListSaveDTO) throws XbbException;

    SupportLinkageFieldsVO supportLinkageFields(ClueConvertRuleSaveDTO clueConvertRuleSaveDTO) throws XbbException;

    BusinessFieldVO fineClueFieldList(BusinessFieldDTO businessFieldDTO) throws XbbException;

    /**
     * 设置阶段流程后返回表单设计页返回当前启用最高优先级流程的阶段信息
     *
     * @param updateExplainStageDTO
     * @return
     * @throws XbbException
     */
    UpdateExplainStageVO updateExplainStage (UpdateExplainStageDTO updateExplainStageDTO) throws XbbException;

    /**
     * 获取自定义字段关联查重字段
     * @param customRepeatLinkExplainDTO
     * @return
     * @throws XbbException
     */
    CustomRepeatLinkExplainGetVO customRepeatLinkExplain(CustomRepeatLinkExplainDTO customRepeatLinkExplainDTO) throws XbbException;

    /**
     * 获取项目决策信息表单
     *
     * @param formGetDTO
     * @return
     * @throws XbbException
     */
    FormDecisionInfoGetVO decisionInfoGet(FormGetDTO formGetDTO) throws XbbException;

    /**
     * 保存项目决策信息表单
     *
     * @param decisionInfoUpdateDTO
     * @return
     * @throws XbbException
     */
    FormUpdateVO decisionInfoUpdate(FormDecisionInfoUpdateDTO decisionInfoUpdateDTO) throws XbbException;
}
